<?php
/**
* 
*/
class CourseCardModel extends MY_Model
{
	
	public function __construct()
	{
		parent::__construct();
		$this->table = 'course_card';
	}


	//获取列表数据
	public function get_list_data($id)
	{
		
		$where = "c.id IS NOT NULL AND c.`status` = 1 AND course_id = '{$id}'";
		$sql = "SELECT card.* FROM ". $this->db->dbprefix."course_card AS card LEFT JOIN ". $this->db->dbprefix."course AS c ON c.id = card.course_id  WHERE {$where}";

		$query = $this->db->query($sql);
		$res = $query->result_array();
		return $res;
	}


	//获取单行数据
	public function get_card_row($card_id)
	{
		$info = $this->_id_get_info($card_id);
		
		return $info;

	}



	//添加入库
	public function inser_card_data($arr=array())
	{
		if ($this->add($arr)) 
		{
			return true;
		}
		else
		{
			return false;
		}

	}

	//更新数据
	public function updata_card_data($arr =array(),$card_id ='')
	{
		if ($this->edit($arr,array('id'=>$card_id))){			
			return true;
		}else{
			return false;
		}

	}


	//删除
	public function remove_card($card_id)
	{
		return $this->del(array('id'=>$card_id));
	}

	function get_all_data(){
		$sql = "SELECT card.* FROM ". $this->db->dbprefix."course_card AS card LEFT JOIN ". $this->db->dbprefix."course AS c ON c.id = card.course_id  WHERE c.id IS NOT NULL AND c.`status` = 1";
		$query = $this->db->query($sql);
		$res = $query->result_array();
		return $res;
	}
}


?>